//
//  ViewController.m
//  6-6.2016
//
//  Created by mac on 16-6-6.
//  Copyright (c) 2016年 hf. All rights reserved.
//

#import "ViewController.h"
#import "ToViewController.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view, typically from a nib.
    self.navigationItem.title = @"14752222";
    self.refreshControl = [UIRefreshControl new];
    self.refreshControl.attributedTitle = [[NSAttributedString alloc]initWithString:@"正在加载。" attributes:@{NSForegroundColorAttributeName:[UIColor blueColor]}];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"停止" style:UIBarButtonItemStylePlain target:self action:@selector(onClink:)];

}

- (void)onClink:(id)sender
{
    [self.refreshControl endRefreshing];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *fen = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
    NSString *imgName = [NSString stringWithFormat:@"%d",indexPath.row + 1];
    fen.imageView.image = [UIImage imageNamed:imgName];
    fen.imageView.layer.cornerRadius = 18;
    fen.imageView.clipsToBounds = YES;
    fen.textLabel.text = @"彩虹鱼,请微笑。";
    fen.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    if (indexPath.row == 0) {
        UISwitch *sw = [UISwitch new];
        [sw sizeToFit];
        fen.accessoryView = sw;
    }
    return fen;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    ToViewController *cn = [ToViewController new];
    [self.navigationController pushViewController:cn animated:YES];
}

    
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
